<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>间隔函数</title>
</head>

<body>
    <script type="text/javascript">
        /* 
         *间隔函数：setInterval(函数名,间隔毫秒数,函数的参数)
         *
         */
        var fn = function() {
                var time = new Date();
                document.write(time + "<br/>");
            }
            //1.启动定时
        var inter = setInterval(fn, 1000);
        //2.十秒后清除定时
        setTimeout(function() {
            clearInterval(inter);
        }, 10000);
    </script>
</body>

</html>